package com.ds.infrastructure.hyperspace.console.controller;


import com.ds.infrastructure.hyperspace.console.model.response.dashboard.SummaryMetricsVO;
import com.ds.infrastructure.hyperspace.console.model.response.result.JsonResult;
import com.ds.infrastructure.hyperspace.console.model.response.result.JsonResultData;
import com.ds.infrastructure.hyperspace.console.model.response.result.JsonResultOk;
import com.ds.infrastructure.hyperspace.console.service.inf.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;


/**
 * @author: yaozhendong
 * @create: 2019-10-31 14:17
 **/

@RestController
@RequestMapping(value = "/dashboard", produces = {"application/json;charset=UTF-8"})
@Api(value = "Manager Dashboard Controller", tags = "Dashboard管理")
public class DashboardController {

    @Autowired
    IEnvironmentService iEnvironmentService;
    @Autowired
    IStageService iStageService;
    @Autowired
    IMetricsManageService iMetricsManageService;
    @Autowired
    INodeMetricsAggregationService iNodeMetricsAggregationService;
    @Autowired
    IMetricsTaskService iMetricsTaskService;
    @Autowired
    IDeployConfigService iDeployConfigService;
    @Autowired
    IMetricsManageService metricsManageService;
    @Autowired
    IDashboardService iDashboardService;

    @GetMapping(value = "/getSummaryMetrics")
    @ApiOperation(value = "获取-汇总指标数据")
    public JsonResultData<SummaryMetricsVO> getSummaryMetrics() {
        SummaryMetricsVO summaryMetricsVO = iDashboardService.getSummaryMetrics();
        return JsonResultData.build(summaryMetricsVO);
    }

    @ApiIgnore
    @GetMapping(value = "/crawlMetrics")
    @ApiOperation(value = "抓取指标")
    public JsonResult crawlMetrics() {
        metricsManageService.crawlMetrics();
        return JsonResultOk.SUCCESS;
    }

    @ApiIgnore
    @GetMapping(value = "/aggregationMetrics")
    @ApiOperation(value = "聚合指标")
    public JsonResult aggregationMetrics() {
        metricsManageService.aggregationMetrics();
        return JsonResultOk.SUCCESS;
    }
}
